/*
 * Author: Alberto De Pena
 * Applied Algorithms
 * cake.cpp
*/
#include <iostream>
#include <fstream>
using namespace std;

static int cakeArray[100000];
static int heightArray[100000];

void main()
{
    ifstream fin;
    ofstream fout;

	fin.open( "cake.in" );
    fout.open( "cake.out" );

    int number, maximum, minimum, searchMaximum, currentMax;

    fin >> number;
    while( number > 0 )
    {
        maximum = 1;
        minimum = 200000000;
        for( int i = 0; i < number; i++ )
            fin >> cakeArray[i];

        for( int i = number - 1; i >= 0; i-- )
        {
            if( i < number - 1 )
            {
                if( cakeArray[i] >= minimum )
                {
                    searchMaximum = 0; 
					currentMax = i + 1;
                    for( int j = i + 1; j < number; j++ )
                    {
                        if( cakeArray[i] >= cakeArray[j] )
                        {
                            if( heightArray[j] > searchMaximum )
                            {
                                searchMaximum = heightArray[j];
                                currentMax = j;
                            }
                        }
                    }
                    heightArray[i] = heightArray[currentMax] + 1;
                    if( heightArray[i] > maximum )
                        maximum = heightArray[i];
                }
                else
                {
                    minimum = cakeArray[i];
                    heightArray[i] = 1;
                }
            }
            else
            {
                minimum = cakeArray[i];
                heightArray[i] = 1;
            }
        }

        fout << maximum << endl;
        fin >> number;
    }

    fin.close();
    fout.close();
}

